__author__ = "Alexandre Lessard"
__copyright__ = "Copyright 2011, Alexandre Lessard"
__credits__ = ["Alexandre Lessard"]
__license__ = "BSD"
__version__ = "0.0.1"
__maintainer__ = "Alexandre Lessard"
__email__ = "alexandre.lessard.ti@gmail.com"
__status__ = "Prototype"

"""Controller module for the contacts pages of the website"""

#Import system
from flask import request, session, g, redirect, url_for, \
     abort, render_template, flash
from simpleAppsSME import app
import simpleAppsSME.modules.base_controller as bctl

class Contacts(bctl.BaseController):
    """Contacts controller class"""
    
    def index(self, contact_id):
        """Page that list all contacts"""
        contactModel = app.factory.model('contacts')
        
        contact_list = contactModel.get_all() 
        return render_template('contacts/list.html', contacts=contact_list)
    
    def details(self, contact_id):
        """Page that list Detailed contact infomation
        identified by the contact_id"""
        return "details"
    
    def add(self, contact_id):
        """Page to add a contact"""
        if request.method == 'POST':
            contactModel = app.factory.model('contacts')
            contactModel.add(request.form)
        return redirect(url_for('init_contacts'))
    
    def modify(self, contact_id):
        """Page to modify a contact identified
        by the contact_id"""
        return "modify"
    
    def get_products(self, contact_id):
        """Page to get all the products from a
        contact identified by a contact_id"""
        return "get_products"
